package xyz.yeidi.service.impl;

import xyz.yeidi.dao.api.OrdersDao;
import xyz.yeidi.dao.impl.OrdersDaoImpl;
import xyz.yeidi.pojo.Orders;
import xyz.yeidi.service.api.OrdersService;
import xyz.yeidi.utils.ConnUtils;

import java.util.List;

/**
 * @Author JIP
 * @Date 2021-08-07 15:22
 * @Version 1.0
 * @Describe :
 */
public class OrdersServiceImpl implements OrdersService {
    OrdersDao ordersDao = new OrdersDaoImpl();

    @Override
    public boolean addOrders(Orders orders) {
        try {
            return ordersDao.addOrders(orders);
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            ConnUtils.close();
        }
        return false;
    }

    @Override
    public Orders getOrdersById(Integer id) {
        try {
            return ordersDao.getOrdersById(id);
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            ConnUtils.close();
        }
        return null;
    }

    @Override
    public boolean deleteOrdersById(Integer id) {
        try {
            return ordersDao.deleteOrdersById(id);
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            ConnUtils.close();
        }
        return false;
    }

    @Override
    public List<Orders> getOrdersByUserId(Integer userId) {
        try {
            return ordersDao.getOrdersByUserId(userId);
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            ConnUtils.close();
        }
        return null;
    }

    @Override
    public List<Orders> getOrdersByBusinessId(Integer businessId) {
        try {
            return ordersDao.getOrdersByBusinessId(businessId);
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            ConnUtils.close();
        }
        return null;
    }

    @Override
    public Integer getOrderIdByUserId(Integer userId) {
        try {
            return ordersDao.getOrderIdByUserId(userId);
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            ConnUtils.close();
        }
        return null;
    }
}
